package com.dlc.shop.platform.task;

import com.xxl.job.core.handler.annotation.XxlJob;
import com.dlc.shop.allinpay.service.AllinpayCompanyService;
import com.dlc.shop.service.ShopDetailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author lth
 * @Date 2021/8/9 14:45
 */
@Slf4j
@Component
@AllArgsConstructor
public class ShopTask {

    private final ShopDetailService shopDetailService;
    private final AllinpayCompanyService allinpayCompanyService;

    /**
     * 根据签约时间改变店铺状态
     */
    @XxlJob("changeShopStatusByContractTime")
    public void changeShopStatusByContractTime() {
        // 根据签约时间修改店铺状态
        if (allinpayCompanyService.getIsAllinpay()) {
            return;
        }
        log.info("根据签约时间改变店铺状态");
        Date now = new Date();
        shopDetailService.changeShopStatusByContractTime(now);
    }
}
